package com.ruoyi.dddetails.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.user.domain.User;
import com.ruoyi.user.domain.vo.UserVO;
import com.ruoyi.user.mapper.UserMapper;
import com.ruoyi.user.service.IUserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.dddetails.mapper.DdDetailsMapper;
import com.ruoyi.dddetails.domain.DdDetails;
import com.ruoyi.dddetails.service.IDdDetailsService;

/**
 * 【叮豆明细】Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-07-02
 */
@Service
public class DdDetailsServiceImpl implements IDdDetailsService 
{
    @Autowired
    private DdDetailsMapper ddDetailsMapper;

    @Autowired
    private UserMapper userMapper;

    /**
     * 查询【请填写功能名称】
     * 
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public DdDetails selectDdDetailsById(Long id)
    {
        return ddDetailsMapper.selectDdDetailsById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param ddDetails 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<DdDetails> selectDdDetailsList(DdDetails ddDetails)
    {
        return ddDetailsMapper.selectDdDetailsList(ddDetails);
    }

    /**
     * 新增【请填写功能名称】
     * 
     * @param ddDetails 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertDdDetails(DdDetails ddDetails)
    {
        ddDetails.setCreateTime(DateUtils.getNowDate());
        return ddDetailsMapper.insertDdDetails(ddDetails);
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param ddDetails 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateDdDetails(DdDetails ddDetails)
    {
        return ddDetailsMapper.updateDdDetails(ddDetails);
    }

    /**
     * 批量删除【请填写功能名称】
     * 
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteDdDetailsByIds(String[] ids)
    {
        return ddDetailsMapper.deleteDdDetailsByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteDdDetailsById(String id)
    {
        return ddDetailsMapper.deleteDdDetailsById(id);
    }

    /**
     * 根据用户id查询用户叮豆明细
     *
     * @param userId
     * @return
     */
    @Override
    public UserVO selectDdDetailsListByUserId(String userId) {
        User user = userMapper.selectUserByUserId(userId);
        UserVO userVO = new UserVO();
        BeanUtils.copyProperties(user, userVO);
        DdDetails ddDetails = new DdDetails();
        ddDetails.setId(userId);
        List<DdDetails> ddDetailsList = ddDetailsMapper.selectDdDetailsList(ddDetails);
        userVO.setDdDetailsList(ddDetailsList);
        return userVO;
    }
}
